package cbir;

public class Thumb {

	public static String getThumb(String file){
		
		
		String ext = file.substring(file.lastIndexOf("."), file.length());
		
		if(ext.compareTo(".png") == 0){
			return file.substring(0, file.indexOf(ext))  +"Thumbpng" + ".jpg";
		}else if(ext.compareTo(".PNG") == 0){
			return file.substring(0, file.indexOf(ext))  +"ThumbPNG" + ".jpg";
		}else if(ext.compareTo(".gif") == 0){
			return file.substring(0, file.indexOf(ext))  +"Thumbgif" + ".jpg";
		}else if(ext.compareTo(".GIF") == 0){
			return file.substring(0, file.indexOf(ext))  +"ThumbGIF" + ".jpg";
		}else{
			return file.substring(0, file.indexOf(ext))  +"Thumb" + ext;
		}
		
	}
	
	public static String getFilename(String thumbname){	
		
			String ext = thumbname.substring(thumbname.lastIndexOf("."), thumbname.length());
			
			if( thumbname.substring(0, thumbname.lastIndexOf(".")).lastIndexOf("ThumbPNG") != -1 )
				return thumbname.substring(0, thumbname.lastIndexOf("ThumbPNG")) + ".PNG";
			else if( thumbname.substring(0, thumbname.lastIndexOf(".")).lastIndexOf("Thumbpng") != -1 )
				return thumbname.substring(0, thumbname.lastIndexOf("Thumbpng")) + ".png";
			if( thumbname.substring(0, thumbname.lastIndexOf(".")).lastIndexOf("ThumbGIF") != -1 )
				return thumbname.substring(0, thumbname.lastIndexOf("ThumbGIF")) + ".GIF";
			else if( thumbname.substring(0, thumbname.lastIndexOf(".")).lastIndexOf("Thumbgif") != -1 )
				return thumbname.substring(0, thumbname.lastIndexOf("Thumbgif")) + ".gif";
			else
				return thumbname.substring(0, thumbname.lastIndexOf("Thumb")) + ext;
	}
}